//
//  Result.swift
//  
//
//  Created by tangbl93 on 2021/2/19.
//

import Foundation

public extension Result {
    
    /// Returns the associated success value if the result is a success, `nil` otherwise.
    var yx_value: Success? {
        switch self {
        case let .success(value):
            return value
        case .failure:
            return nil
        }
    }
    
    /// Returns the associated error value if the result is a failure, `nil` otherwise.
    var yx_error: Failure? {
        switch self {
        case .success:
            return nil
        case let .failure(error):
            return error
        }
    }
}
